<@override name="content">
<form class="ui large form" method="post" role="form" id="regeist-form" style="margin-top: 50px;margin-left: 400px;margin-right: 400px;">
    <input type="hidden" name="id" value="${session.user.id}">
    <div class="form-group">
        <label>昵　称：</label>
        <input type="text" class="form-control" name="nickname" autocomplete="off" value="${session.user.nickname}"></br>
    </div>
    <div class="form-group">
        <label>邮　箱：</label>
        <input type="text" class="form-control" name="email" autocomplete="off" value="${session.user.email}"></br>
    </div>
    <div class="ui error message"></div>
    <input type="button" class="ui fluid primary blue button" value="修改" onclick="login()">
</form>

<script type="text/javascript" language="JavaScript">

    $('#regeist-form').form({
        fields:{
            nickname:{
                rules:[{
                    type:'empty',
                    prompt:'昵称不能为空'
                }]
            },
            email:{
                rules:[{
                    type:'email',
                    prompt:'邮箱格式不正确'
                }]
            },
        }
    });

    function login() {
        $('#regeist-form').form('validate form');
        if ($('#regeist-form').form('is valid')){
            $.ajax({
                url:'${base}/user/modifydeal',
                type:'POST',
                data:$('#regeist-form').serialize(),
                success:function(res){
                    if(res.success){
                        location.href='${base}/main';
                    }else{
                        $("#regeist-form :input").not(":button, :submit, :reset, :hidden, :checkbox, :radio").val("");
                        $("#regeist-form :input").removeAttr("checked").remove("selected");
                    }
                }
            });
        }
    }

</script>

</@override>

<@extends name="../parent1.ftl"></@extends>